#ifndef GAME_RESOURCES_H
#define GAME_RESOURCES_H

class GameResources;

#include <ios>
#include <fstream>

#include "Configuration.h"
#include "Level.h"
#include "Constants.h"
#include "PodServerInterface.h"
#include "AudioInterface.h"
#include "ReplayRecorder.h"
#include "InputDevice.h"
#include "Mouse.h"
#include "Joystick.h"
#include "Keyboard.h"
#include "CameraControl.h"
#include "FirstPersonCamera.h"
#include "ThirdPersonCamera.h"
#include "SkyBox.h"
#include "HighScore.h"
#include "LevelLocks.h"

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32

    #define MAX_CONSOLE_LINES 500
    #include <io.h>
    #include <fcntl.h>

#endif

class GameResources : public Ogre::FrameListener
{
    private:
	    void createRoot();
	    void defineResources();
	    void loadConfiguration();
	    void defineLevels();
	    void setupRenderSystem();
	    void createRenderWindow();
	    void initializeResourceGroups();
	    void setupSceneManager();
	    void setupViewport();
	    void setupInputSystem();
	    void setupCameras();
	    void setupCEGUI();
	    void setupOgreNewt();
	    void setupAudio();
        void windowResized(Ogre::RenderWindow *rw);
        void loadHighScores();

    public:
        static const int MOUSE        = OIS::KC_1;
        static const int KEYBOARD     = OIS::KC_2;
        static const int JOYSTICK     = OIS::KC_3;
        static const int POD_JOYSTICK = OIS::KC_4;
        
        // Pod variables
        bool pod_control;
        bool pod_config_file;
        PodServerInterface *pod;
        Configuration *config;
        
        // Ogre stuff
	    Ogre::Root *ogre;
	    Ogre::RenderWindow *render_window;
	    Ogre::SceneManager *scene_manager;
	    OgreNewt::World *ogre_newt;
	    
	    // Level Resources
	    SkyBox *skyBox;
	    
	    // Input device variables
	    OIS::InputManager *input_manager;
	    Mouse *mouse;
	    Joystick *joystick;
	    Keyboard *keyboard;
	    InputDevice *current_device;
	    
	    // Cameras
	    FirstPersonCamera *first_person_camera;
	    ThirdPersonCamera *third_person_camera;
	    CameraControl *current_camera;
	    Ogre::Camera *main_gui_camera, *left_gui_camera, *right_gui_camera;
	   
	    // Audio
	    AudioInterface *audio;

        // High Scores
        HighScore *scores;
        
        // GUI stuff
	    CEGUI::System *GUISystem;
	    CEGUI::OgreCEGUIRenderer *GUIRenderer;
	    static LevelVector levels;
	    static LevelVector bonusLevels;
	    static Level *current_level;

	    GameResources(bool pod_ctl, bool pod_cfg);
       ~GameResources();
};

#endif
